﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////


#pragma once        
#include "IFamilyConstraintGroup.h"
#include "GmFamilyService.h"

namespace gcmp
{
    class ILine3d;
    class IModelView;
}

namespace gfam
{

    /// \brief 连续尺寸标注
    class GM_FAMILY_SERVICE_EXPORT IFamilyMultiDistanceDimension : public IFamilyConstraintGroup
    {
        DEFINE_CAST_DERIVED(gfam::IFamilyMultiDistanceDimension, gfam::IFamilyConstraintGroup)
    public:

        /// \brief 创建连续尺寸标注
        ///
        /// \param pDocument 文档
        /// \param sketchId 所属草图id
        /// \param option 创建选项
        /// \return 连续尺寸标注
        static IFamilyMultiDistanceDimension* Create(gcmp::IDocument* pDocument, const gcmp::ElementId& sketchId, gcmp::ElementCreationOptions eco = gcmp::ElementCreationOptions::Normal);

        /// \brief 创建连续尺寸标注
        ///
        /// \param pDocument 文档
        /// \param position 位置
        /// \param scale 尺寸缩放值
        /// \param idSketchPlane 草图平面id
        /// \param idSketch 所属草图id
        /// \param bEqual   是否相等
        /// \param option 创建选项
        /// \return 连续尺寸标注
        static IFamilyMultiDistanceDimension*Create(
            gcmp::IDocument* pDocument
            , const gcmp::Vector3d&position
            , double scale
            , const gcmp::ElementId&idSketchPlane
            , const gcmp::ElementId&idSketch
            , const gcmp::Coordinate3d& coord
            , bool bEqual
            , gcmp::ElementCreationOptions option = gcmp::ElementCreationOptions::Normal
        );

        /// \brief 获取方向
        ///
        /// \return 方向
        virtual gcmp::Vector3d GetDirection() const = 0;

        /// \brief 设置位置
        ///
        /// \param position位置
        virtual void SetPosition(const gcmp::Vector3d& position) = 0;

        /// \brief 设置等距
        ///
        /// \param equal 是否等距
        virtual void SetEqual(bool equal) = 0;

        /// \brief 获取是否等距
        ///
        /// \return 等距返回true,否则返回false
        virtual bool IsEqual() const = 0;

        /// \brief 获取方向引用的第一个对象
        ///
        /// \return 节点引用
        virtual const gcmp::IGraphicsNodeReference* GetFirstDirectionalRefObj() const = 0;

        /// \brief 获取坐标系
        ///
        /// \return 坐标系
        virtual gcmp::Coordinate3d GetCoordinate() const = 0;

        /// \brief 设置坐标系
        ///
        /// \param coord 坐标系
        virtual void SetCoordinate(const gcmp::Coordinate3d& coord) = 0;

        /// \brief 获取引用对象
        ///
        /// \return 引用对象
        virtual const std::vector<gcmp::OwnerPtr<gcmp::IGraphicsNodeReference>>& GetReferenceObjects() const = 0;

        /// \brief 添加引用对象
        ///
        /// \param referenceObject引用对象
        /// \return 操作成功返回true,否则返回false
        virtual bool AddReferenceObject(gcmp::OwnerPtr<gcmp::IGraphicsNodeReference> referenceObject) = 0;

        /// \brief 获取关联平面id
        ///
        /// \return 关联平面id
        virtual gcmp::ElementId GetAssociatedPlaneId() const = 0;

        /// \brief 设置关联平面id（草图平面或者参照平面）
        ///
        /// \param id 平面id
        virtual void SetAssociatedPlaneId(const gcmp::ElementId& id) = 0;

        /// \brief 获取草图id
        ///
        /// \return 草图id
        virtual gcmp::ElementId GetSketchId() const = 0;

        /// \brief 设置草图id
        ///
        /// \param sketchId 草图id
        virtual bool SetSketchId(const gcmp::ElementId& sketchId) = 0;

        /// \brief 获取草图外是否可见
        ///
        /// \return 草图外是否可见
        virtual bool IsVisibleOutOfSketch() = 0;

        /// \brief 获取是否是等距约束
        ///
        /// \return 是否是等距约束
        virtual bool IsDistanceEqual() const = 0;

        /// \brief 设置为等距约束
        ///
        /// \param equal 是否等距
        /// \param forceUpdate 是否强制更新管理的约束
        /// \return 操作成功返回true,否则返回false
        virtual bool SetToEQConstraint(bool equal, bool forceUpdate = false) = 0;

        /// \brief 根据拾取线的方向进行排序
        virtual void SortReferenceObjects() = 0;

        /// \brief 根据引用对象计算并设置尺寸线方向
        virtual void UpdateDimensionDirection() = 0; 

        /// \brief 获取与射线相交的约束
        ///
        /// \param ray 射线
        /// \param pModelView 视图指针
        /// \return 返回射线相交的约束id
        virtual gcmp::ElementId GetIntersectConstraint(const gcmp::ILine3d* ray, const gcmp::IModelView* pModelView) = 0;

        /// \brief 设置主对象的Id
        /// 主对象指具有强依赖关系的对象，当主对象被删除时，从对象也会被删除。
        ///
        /// \param masterId 主对象Id
        /// \return void
        virtual void SetMasterId(gcmp::ElementId masterId) = 0;

    };
}